package main

import (
	"GoLangTest/config"
	"GoLangTest/router/calendarAlarmRouter"
	"GoLangTest/service/calendarAlarmService"
	"fmt"
	"github.com/gin-gonic/gin"
	_ "github.com/go-sql-driver/mysql"
	"time"
)

func main() {
	config.ConnectToDatabase()
	_, _ = time.LoadLocation("Asia/Shanghai")
	r := gin.Default()
	calendarAlarmRouter.Routers(r)

	//异步操作实现所有用户的日历提醒功能
	_ = make(chan string)
	go func() {
		for {
			calendarAlarmService.AlarmUser()
			time.Sleep(3 * time.Second) //实际操作这里应该用分钟刷新
			fmt.Println("--------------------")
		}
	}()

	_ = r.Run(":8080") // 默认8080
}
